﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CIT.WMS.Other
{
    public partial class FrmGMLabelCheck : Form
    {
        public FrmGMLabelCheck()
        {
            InitializeComponent();
        }

        private void clearBoxLbl()
        {
            areaMsg.Text = "条码格式不正确，请确认！";
            txtBoxLablel.Text = "";
            txtBoxLablel.Focus();
        }
        private void clearPalletLbl()
        {
            areaMsg.Text = "条码格式不正确，请确认！";
            this.txtPalletLablel.Text = "";
            this.txtPalletLablel.Focus();
        }
        private string CheckString = "";
        private string PalletString = "";
        private void txtBoxLablel_KeyPress(object sender, KeyPressEventArgs e)
        {
            areaInfo.Text = "";
            if (e.KeyChar != 13)
            {
                return;
            }

            try
            {
                this.txtPalletLablel.Focus();
            }
            catch
            {
                clearBoxLbl();
                return;
            }
        }

        private void txtPalletLablel_KeyPress(object sender, KeyPressEventArgs e)
        {
            areaInfo.Text = "";
            if (e.KeyChar != 13)
            {
                return;
            }

            try
            {
                var ptNumber = txtPalletLablel.Text.Substring(10, txtPalletLablel.Text.Length - 10);
                ptNumber = ptNumber.Substring(0, txtBoxLablel.Text.Length);

                if (ptNumber.Equals(txtBoxLablel.Text))
                {
                    areaInfo.Text = "Validation \r\nOK ";
                }
                else
                {
                    areaInfo.Text = "Validation \r\nNG";
                    MessageBox.Show("NG");
                }
                clearBoxLbl();
                clearPalletLbl();
                areaMsg.Text = "";
            }
            catch
            {
                clearPalletLbl();
                return;
            }
        }

        //END
    }
}